<script>
    
    $(document).ready(function(){
        
      $("#submit").click(function(){
          var first_name=$("#first_name").val();
        $.post(
            "/registration/checkregistration", 
            { 
               regdata:$("#user_new").serialize(),
            },
            function(data){
                
                if(data.status=="failed"){
                    $("label[for=first_name]").text(data.firstname);
                    $("label[for=last_name]").text(data.lastname);
                    $("label[for=user_password]").text(data.password2);}
            //$("label[for=email]").text(data.email);}
                else if(data.status=="success"){
                    $("#model").remove();
                   // $("#login").remove();
                    $("#user_in").removeClass("logged-in").addClass("logged-out");
                    $("#user_out").removeClass("logged-out").addClass("logged-in");
                    $("#user_name").text(first_name) ;
                    //$("#user_menu")
                    
                    
                }
                
               // $("#list-your-space").text(html);
            }, 
            "json"
        );
        event.preventDefault();
      });
      $("input[type=email]").focusout(function () { 
          var re=/^(([a-zA-Z0-9_\-.]+)@([a-zA-Z0-9\-]+)\.[a-zA-Z0-9\-.]+$)/;
          
          if(!re.test($("input[type=email]").val())){
              //действие при неправильной валидации
          } else {$("input[type=email]").addClass("valid"); }
      
    }); 
      
    });
</script>

<div id="model" class="modal" aria-hidden="false"><div class="modal-table"><div class="modal-cell"><div class="signup modal-content">
  <div id="notice" class="alert panel-header alert-header alert-danger alert-error hidden-element"></div>
<div id="conteiner">
<div class="panel-padding panel-body">

    
<a href="https://www.facebook.com/v2.0/dialog/oauth?client_id=138566025676&amp;redirect_uri=https%3A%2F%2Fru.airbnb.com%2Fauthenticate&amp;scope=email%2Cuser_birthday%2Cuser_likes%2Cuser_education_history%2Cuser_hometown%2Cuser_interests%2Cuser_activities%2Cuser_location%2Cuser_friends%2Cpublish_actions" class="fb-button fb-blue btn icon-btn btn-block padded-btn-block row-space-1 btn-large large btn-facebook" data-populate_uri="" data-redirect_uri="https://ru.airbnb.com/authenticate">
	<span class="icon-container">
    <i class="icon icon-facebook"></i>
	</span>
	<span class="text-container">
    Зарегистрироваться с помощью Facebook
  </span>
</a>

    
<a href="/oauth_connect?service=google&amp;from=google_signup" class="btn icon-btn btn-block padded-btn-block row-space-1 btn-large large btn-google">
  <span class="icon-container">
    <i class="icon icon-google-plus"></i>
  </span>
  <span class="text-container">
    Зарегистрироваться с помощью Google
  </span>
</a>

    <div class="signup-or-separator">
      <h6 class="shift text text-special">или</h6>
      <hr>
    </div>

    <div class="text-center" id="reg">
      <a href="/signup_login?sm=2" class="create-using-email btn-block padded-btn-block  row-space-2 btn btn-primary btn-block btn-large large icon-btn">
          <i class="icon icon-envelope"></i>
          Регистрация через E-mail
</a>    </div>

  <form accept-charset="UTF-8" action="/create" class="signup-form" data-action="Signup" id="user_new" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"><input name="authenticity_token" type="hidden" value="V4$.airbnb.com$YaIjnWDzsv8$DvhCgwFU--LakLRbCWDkZ1K7f71EQ-xt19jPJYI0Yv4="></div>
    <div class="signup-form-fields  hidden-element">
         
<div class="control-group row-space-1" id="inputFirst">
  <label for="first_name" generated="false" class="error"></label>
  <input type="text" name="user[first_name]" placeholder="Имя" id="first_name" class="decorative-input" value="">
</div>
<div class="control-group row-space-1" id="inputLast">
  <label for="last_name" generated="true" class="error"></label>
  <input type="text" name="user[last_name]" placeholder="Фамилия" class="decorative-input" value="">
</div>
<div class="control-group row-space-1" id="inputEmail">
  <input type="email" name="user[email]" placeholder="Электронная почта" class="decorative-input" value="">
</div>
<div class="control-group row-space-1" id="inputPassword">
  <label for="user_password" generated="true" class="error"></label>
  <input type="password" id="user_password" name="user[password]" placeholder="Пароль" class="decorative-input">
</div>
<div class="control-group row-space-1" id="inputConfirmPassword">
  <label for="password_confirmation" generated="true" class="error"></label>
  <input type="password" name="user[password_confirmation]" placeholder="Подтвердите пароль" class="decorative-input">
</div>
<label for="user_profile_info_receive_promotional_email" class="checkbox">
<input name="user_profile_info[receive_promotional_email]" type="hidden" value="0">
<input checked="checked" id="user_profile_info_receive_promotional_email" name="user_profile_info[receive_promotional_email]" type="checkbox" value="1">
  Сообщать мне о новостях Airbnb
</label>

      
      <button type="submit" class="btn btn-primary btn-block btn-large large padded-btn-block" id="submit">
        Зарегистрироваться
      </button>
    </div>
</form>
    <div id="tos_outside" class="row-space-top-2">
      <small>
  Регистрируясь, вы соглашаетесь с <a href="/terms" data-popup="true">Условия предоставления услуг</a>, <a href="/terms/privacy_policy" data-popup="true">Политика конфиденциальности</a>, <a href="/terms/guest_refund_policy" data-popup="true">Правила компенсации гостю</a> и <a href="/terms/host_guarantee" data-popup="true">Условия Гарантии для хозяев</a> Airbnb.
</small>

    </div>
</div>
    </div>

<div class="panel-body">
  Вы уже на Airbnb?
    <a href="/login" class="modal-link" data-modal-href="/login_modal">
    Войти
</a></div>


  <form accept-charset="UTF-8" action="/authenticate" class="hide hidden-element in_modal" id="facebook_form" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"><input name="authenticity_token" type="hidden" value="V4$.airbnb.com$YaIjnWDzsv8$DvhCgwFU--LakLRbCWDkZ1K7f71EQ-xt19jPJYI0Yv4="></div>
    
    
</form>
  </div></div></div></div>
